package com.woniu.dao;

import com.woniu.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

public interface AliPayDao {
    // 插入订单
    int insertOrder(Order order);

    // 插入订单课程关联
    int insertOrderCourse(@Param("orderId") String orderId, @Param("courseId") Integer courseId);

    // 更新订单状态
    int updateOrderStatus(@Param("orderId") String orderId,
                          @Param("status") Integer status,
                          @Param("orderMethod") String orderMethod);
    @Select("select balance from user where user_id=#{userid}")
    BigDecimal getUserBalance(Integer userid);

    /**
     * 开始付款
     */
    @Update("update user set balance=#{nowBalance} where user_id=#{userId}")
    void killBalance(Integer userId, BigDecimal nowBalance);

    /**
     * 插入数据到用户和课程的中间表
     */

    @Insert("INSERT INTO user_course SET user_id = #{userId}, course_id = #{courseId}, is_charge = 1")
    void insertIntoUserCourse(Integer userId,Integer courseId);
}
